﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using Antu.WebControls;
using Antu.Core.Components;
using Antu.Core.Services;
using System.Web.UI.WebControls;
using EluZSProvider;
using System.Web;
using System.Data;

namespace WebSys.UI.Control.ZhengShou
{
    public class SetYuJingControl : MPBasicTemplate
    {
        EluZSDataProvider _EluZSDataProvider = (EluZSDataProvider)ProviderService.ProviderServiceMange.GetProvider("EluZSProvider");
        public string userid = string.Empty;
        CheckBox CheckBox1, CheckBox2, CheckBox3, CheckBox4, CheckBox5,
            CheckBox6, CheckBox7, CheckBox8, CheckBox9, CheckBox10;
        TextBox txt补偿装修费用预警值, txt余额警戒值,
            txt安置房源面积小于被征收面积, txt补偿装修费用已超过预警值,
            txt补偿价款已超过房屋均价, txt余额已低于警戒值,
            txt账户余额为零, txt存在部分协议补偿款未支付,
            txt到账余额已小于补偿额度, txt补偿总价小于评估总价,
            txt补偿总价超出评估总价, txt协议补偿款未支付;
        protected override void OnLoad(EventArgs e)
        {
            if (HttpContext.Current.Session["UserID"] == null)
            {
                Antu.Utilities.UtilitiesPage.AlertDialogClear("登录超时，请重新登录！", "window.parent.location.href('../login.aspx');");
            }
            else
            {
                userid = HttpContext.Current.Session["UserID"].ToString();
            }
            base.OnLoad(e);
            InitControl();
            if (!base.Page.IsPostBack) {
                Bind();    
            }
            
            Button btn_Insert = (Button)FindControl("btn_Insert");
            btn_Insert.Click += new EventHandler(btn_Insert_Click);
        }
        protected void InitControl() {
            CheckBox1 = (CheckBox)FindControl("CheckBox1");
            CheckBox2 = (CheckBox)FindControl("CheckBox2");
            CheckBox3 = (CheckBox)FindControl("CheckBox3");
            CheckBox4 = (CheckBox)FindControl("CheckBox4");
            CheckBox5 = (CheckBox)FindControl("CheckBox5");

            CheckBox6 = (CheckBox)FindControl("CheckBox6");
            CheckBox7 = (CheckBox)FindControl("CheckBox7");
            CheckBox8 = (CheckBox)FindControl("CheckBox8");
            CheckBox9 = (CheckBox)FindControl("CheckBox9");
            CheckBox10 = (CheckBox)FindControl("CheckBox10");

            txt补偿装修费用预警值 = (TextBox)FindControl("txt补偿装修费用预警值");
            txt余额警戒值 = (TextBox)FindControl("txt余额警戒值");
            txt安置房源面积小于被征收面积 = (TextBox)FindControl("txt安置房源面积小于被征收面积");
            txt补偿装修费用已超过预警值 = (TextBox)FindControl("txt补偿装修费用已超过预警值");
            txt补偿价款已超过房屋均价 = (TextBox)FindControl("txt补偿价款已超过房屋均价");

            txt余额已低于警戒值 = (TextBox)FindControl("txt余额已低于警戒值");
            txt账户余额为零 = (TextBox)FindControl("txt账户余额为零");
            txt存在部分协议补偿款未支付 = (TextBox)FindControl("txt存在部分协议补偿款未支付");
            txt到账余额已小于补偿额度 = (TextBox)FindControl("txt到账余额已小于补偿额度");
            txt补偿总价小于评估总价 = (TextBox)FindControl("txt补偿总价小于评估总价");

            txt补偿总价超出评估总价 = (TextBox)FindControl("txt补偿总价超出评估总价");
            txt协议补偿款未支付 = (TextBox)FindControl("txt协议补偿款未支付");


        }
        private void Bind()
        {
            EluZSProvider.YJCS yjcs = _EluZSDataProvider.GetYJCS();
            string tt1 = yjcs.安置房源面积小于被征收面积;
            string tt2 = yjcs.补偿装修费用已超过预警值;
            string tt3 = yjcs.补偿价款已超过房屋均价;
            string tt4 = yjcs.余额已低于警戒值;
            string tt5 = yjcs.账户余额为零;
            string tt6 = yjcs.存在部分协议补偿款未支付;
            string tt7 = yjcs.到账余额已小于补偿额度;
            string tt8 = yjcs.补偿总价小于评估总价;
            string tt9 = yjcs.补偿总价超出评估总价;
            string tt10 = yjcs.协议补偿款未支付;
            txt补偿装修费用预警值.Text = yjcs.补偿装修费用预警值;
            txt余额警戒值.Text = yjcs.余额警戒值;
            txt安置房源面积小于被征收面积.Text= yjcs.安置房源面积小于被征收面积;
            txt补偿装修费用已超过预警值.Text=yjcs.补偿装修费用已超过预警值;
            txt补偿价款已超过房屋均价.Text=yjcs.补偿价款已超过房屋均价;

            txt余额已低于警戒值.Text=yjcs.余额已低于警戒值;
            txt账户余额为零.Text=yjcs.账户余额为零;
            txt存在部分协议补偿款未支付.Text=yjcs.存在部分协议补偿款未支付;
            txt到账余额已小于补偿额度.Text=yjcs.到账余额已小于补偿额度;
            txt补偿总价小于评估总价.Text=yjcs.补偿总价小于评估总价;

            txt补偿总价超出评估总价.Text=yjcs.补偿总价超出评估总价;
            txt协议补偿款未支付.Text=yjcs.协议补偿款未支付;
            if (tt1 == "1")
            {
                CheckBox1.Checked = true;
            }
            if (tt2 == "1")
            {
                CheckBox2.Checked = true;
            }
            if (tt3 == "1")
            {
                CheckBox3.Checked = true;
            }
            if (tt4 == "1")
            {
                CheckBox4.Checked = true;
            }
            if (tt5 == "1")
            {
                CheckBox5.Checked = true;
            }
            if (tt6 == "1")
            {
                CheckBox6.Checked = true;
            }
            if (tt7 == "1")
            {
                CheckBox7.Checked = true;
            }
            if (tt8 == "1")
            {
                CheckBox8.Checked = true;
            }
            if (tt9 == "1")
            {
                CheckBox9.Checked = true;
            }
            if (tt10 == "1")
            {
                CheckBox10.Checked = true;
            }
        }
        protected void btn_Insert_Click(object sender, EventArgs e)
        {
            EluZSProvider.YJCS yjcs = _EluZSDataProvider.GetYJCS();

            yjcs.补偿装修费用预警值 = txt补偿装修费用预警值.Text;
            yjcs.余额警戒值 = txt余额警戒值.Text;
            yjcs.安置房源面积小于被征收面积 = txt安置房源面积小于被征收面积.Text;
            yjcs.补偿装修费用已超过预警值 = txt补偿装修费用已超过预警值.Text;
            yjcs.补偿价款已超过房屋均价 = txt补偿价款已超过房屋均价.Text;

            yjcs.余额已低于警戒值 = txt余额已低于警戒值.Text;
            yjcs.账户余额为零 = txt账户余额为零.Text;
            yjcs.存在部分协议补偿款未支付 = txt存在部分协议补偿款未支付.Text;
            yjcs.到账余额已小于补偿额度 = txt到账余额已小于补偿额度.Text;
            yjcs.补偿总价小于评估总价 = txt补偿总价小于评估总价.Text;

            yjcs.补偿总价超出评估总价 = txt补偿总价超出评估总价.Text;
            yjcs.协议补偿款未支付 = txt协议补偿款未支付.Text;
            bool save = _EluZSDataProvider.SaveYJCS(yjcs);
            if (save) {
                Antu.Utilities.UtilitiesPage.AlertDialog("保存成功！", "window.location.href=window.location.href;");
            }
        }
    }
}


